/*
 * iom8535_user.h
 *
 *  Created on: 21.04.2012
 *      Author: alex
 */

#ifndef IOM8535_USER_H_
#define IOM8535_USER_H_

#define FREQ_10ms_TICKS 78
#define FREQ_10ms_PRESC 7
#define FREQ_40us_TICKS 40
#define FREQ_40us_PRESC 2
#define FREQ_1p5ms_TICKS 188
#define FREQ_1p5ms_PRESC 3

#define FREQ_MHZ	8
#define	TIMER_PRESCALER   2
//prescaler is freq/8
#define SET_RS	PORTC|=1<<4
#define UNSET_RS PORTC&=!1<<4
#define SET_RW	PORTC|=1<<3
#define UNSET_RW PORTC&=!1<<3
#define SET_E PORTC|=1<<2
#define UNSET_E PORTC&=!1<<2

uint8 twi_start();
uint8 twi_stop();
uint8 twi_adr(char a);
uint8 twi_send(uint8 num, uint8 *a);
uint8 twi_send_single(uint8 a);
uint8 twi_read(uint8 num, uint8 *a);
uint8 twi_read_single(uint8 *a);
void twi_init();
void wait_ticks(char ticks, char presc);
void timers_init();
void pause_thread(char thread_ind, uint16 val);

#endif /* IOM8535_USER_H_ */
